<template>
	<view class="page-body login_container">
		<view class="login">
			<!-- <image src="../../static/logo-freebsd-devil.svg"></image> -->
			<view style="text-align: center;margin-top: 30upx;">
				<text class="iconfont icon-logo-freebsd-devil logo"></text>
			</view>
			<input v-model="submitData.username" type="text" placeholder="用户名" />
			<input v-model="submitData.password" type="password" placeholder="密码" />
			<button @click="login" type="info">登陆</button>
			<view class="flexAround">
				<text @click="register">注册账号</text>
				<text @click="password">忘记密码</text>
			</view>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				submitData: {
					username: 'super_admin',
					password: 'lak110110'
				},
				userInfo: {}
			};
		},
		methods: {
			login() {
				this.$axios.post('userLogin/moreHandle', this.submitData, (p) => {
					if (p.data.result.length > 0) {
						uni.setStorageSync('userInfo', JSON.stringify(p.data.result[0]));
						uni.switchTab({
							url: '../tabBar/component/component'
						});
					}
				})
			},
			getWebToken() {
				this.$axios.get('userLogin/getToken', '', (p) => {
					uni.setStorageSync('authorization', p.data.result);
				})
			},

			register() {
				uni.navigateTo({
					url: './register'
				})

			},
			password() {
				uni.navigateTo({
					url: './password'
				})
			}
		},
		created() {
			this.userInfo = uni.getStorageSync('userInfo');
			console.log(this.userInfo)
			if (this.userInfo) {
				uni.switchTab({
					url: '../tabBar/component/component'
				});
			}
		},
		mounted() {
			// this.getWebToken();
		},
		onLoad(option) { //option为object类型，会序列化上个页面传递的参数
			if(option.info)
			{
				this.submitData=JSON.parse(option.info)
			}
		}
	}
</script>

<style>
	.login_container {
		display: flex;
		justify-content: center;
		width: 100%;
		/* 	height: 100%;
		position: absolute; */

	}

	button,
	input {
		margin-top: 30upx;
		margin-bottom: 30upx;
	}

	input {
		height: 80upx;
		border: 1px solid #F0F0F0;
		border-radius: 8upx;
		padding-left: 20upx;
	}

	.login {
		width: 90%;
	}

	.login image {
		width: 90px;
		margin: 30px auto 40px;
		display: block;
		height: 90px;
		border: 1px solid #F0F0F0;
		border-radius: 100%;
	}

	.flexAround {
		margin-top: 40upx;
	}

	.flexAround text {
		color: #108EE9;
	}

	.logo {
		font-size: 180upx;
		border: 1px solid #F0F0F0;
		padding: 20upx;
		border-radius: 100%;
		color: #108EE9;
	}
</style>
